from droidguide_classes import Landmark

import os
import wsgiref.handlers
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template

class LandmarkControler:
	
	class Add(webapp.RequestHandler):
		def get(self):
			l = Landmark()
			l.title = self.request.get('title')
			l.description = self.request.get('desc')
			l.lat = float(self.request.get('lat'))
			l.lon = float(self.request.get('lon'))
			l.save()
			self.response.out.write(l.title)
	
	class AddForm(webapp.RequestHandler):
    		def get(self):
			template_values = {}
			path = os.path.join(os.path.dirname(__file__), 'templates/add_landmark.html')
			self.response.out.write(template.render(path, template_values))

	class KMLLandmarks(webapp.RequestHandler):
		def get(self, userid):
			landmarks = Landmark.all()
			template_values = {'landmarks': landmarks, 'userid': userid}
			path = os.path.join(os.path.dirname(__file__), 'templates/landmark.kml')
			self.response.out.write(template.render(path, template_values))

